import tkinter
import tkinter.filedialog
def FileOpen_():
    r=tkinter.filedialog.askopenfilename(title='Python',filetypes=[('Python','*.py *.pyw'),('All files','*')])
    print(r)
def FileSave():
    r=tkinter.filedialog.asksaveasfilename(title='Python',
                                           initialdir=r'D:\Python project',
                                           initialfile='file.py')
    print(r)
root=tkinter.Tk()
button1=tkinter.Button(root,text='打开文件',command=FileOpen_())
button1.pack(side='left')
button2=tkinter.Button(root,text='保存文件',command=FileSave())
button2.pack(side='left')
root.mainloop()